<template>
  <div>
    <div class="container">
      <div class="nav">
        <div>
          <a href="javascript:;" @click="$router.back()"></a>
        </div>
        <div>
          <span>{{ allData.name }}</span>
        </div>
        <div @click="subnav = !subnav">
          <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i>
          <div class="subnav" v-show="subnav">
            <router-link to="/" tag="a">首页</router-link>
            <router-link to="/news" tag="a">资讯</router-link>
            <router-link to="/video" tag="a">视频</router-link>
            <router-link to="/seek" tag="a">找车</router-link>
            <router-link to="/plaint" tag="a">汽车投诉</router-link>
          </div>
        </div>
      </div>
      <div class="car_info">
        <div class="img">
          <img :src="allData.src" alt="" />
        </div>
        <div class="txt">
          {{ allData.name }}
        </div>
      </div>

      <div v-for="(item, index) in allData.type" :key="index">
        <p class="p_tit">
          {{ item.type }}
        </p>
        <div class="maject">
          <router-link
            :to="{
              path: '/carAbout',
              query: { userId: dataId, index, id: ind },
            }"
            tag="div"
            class="item"
            v-for="(val, ind) in item.prop"
            :key="ind"
          >
            <div class="img">
              <img :src="val.src" alt="" />
            </div>
            <div class="txt">
              <h4>{{ val.name }}</h4>
              <span> {{ val.price }}</span>
            </div>
          </router-link>
        </div>
      </div>

      <div class="group">
        <div class="col">
          <div class="first">
            <strong>ID.AERO团购</strong>
          </div>
          <div class="second">大众CC团购</div>
          <div class="last">凌渡团购</div>
        </div>
        <div class="col">
          <div class="second">途锐团购</div>
          <div class="last">帕萨特团购</div>
          <div class="first">蔚揽（进口）团购</div>
        </div>
      </div>
      <div class="search_foot">
        <div></div>
      </div>
    </div>
  </div>
</template>

<script>
import { getJsonCarList } from "../api/carlist";
export default {
  data() {
    return {
      allData: {
        name: "车名",
      },
      dataId: null,
      subnav: false,
    };
  },
  methods: {
    fun() {
      this.dataId = this.$route.query.userId;
      // console.log("ID",this.dataId);
      getJsonCarList().then((data) => {
        // console.log("DATA",data);
        this.allData = data[this.dataId];
        // console.log(this.allData);
      });
    },
  },
  created() {
    this.$emit("car-show", true);
    this.fun();
  },
};
</script>

<style lang="scss" scoped>
.nav {
  height: 44px;
  background-color: #35447b;
  display: flex;
  align-items: center;

  & > div {
    &:nth-child(1) {
      text-align: left;
      flex: 1;
    }

    &:nth-child(2) {
      text-align: center;
      flex: 1;
    }

    &:nth-child(3) {
      text-align: right;
      flex: 1;
      padding-right: 10px;
      position: relative;
      i {
        display: block;
        float: right;
      }
      .subnav {
        width: 100px;
        height: 170px;
        padding: 6px;
        border-radius: 4px;
        position: absolute;
        top: 35px;
        left: 12px;
        background: rgba(0, 0, 0, 0.8);
        z-index: 9;
        a {
          width: 100px;
          height: 18px;
          padding: 8px 0;
          text-align: center;
          background-image: none;
          color: #fff;
        }

        &::before {
          content: "";
          display: block;
          position: absolute;
          top: -17px;
          left: 80px;
          border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
          border-width: 9px;
          border-style: dashed dashed solid dashed;
        }
      }
    }
  }

  div {
    a {
      display: block;
      width: 40px;
      height: 40px;
      background-image: url("../assets/img/icons1.png");
      background-position: -82px -32px;
      background-size: 400px auto;
    }

    span {
      color: #fff;
      font-size: 18px;
    }

    i {
      width: 25px;
      height: 22px;
      background-image: url("../assets/img/icons1.png");
      background-position: -175px -42px;
      background-size: 400px auto;
    }
  }
}

.car_info {
  padding: 15px 10px;
  height: 62px;
  display: flex;

  .img {
    flex: 1;

    img {
      width: 52px;
      height: 52px;
      margin: 5px auto;
    }
  }

  .txt {
    flex: 5;
    line-height: 62px;
    text-indent: 10px;
    font-size: 16px;
    color: #333;
    font-weight: 700;
  }
}

.p_tit {
  height: 34px;
  line-height: 34px;
  color: #999;
  font-size: 12px;
  background-color: #eee;
  text-indent: 12px;
}

.maject {
  padding: 10px 10px 30px 10px;

  .item {
    height: 62px;
    padding: 15px 0 10px 0;
    display: flex;
    border-bottom: 1px solid #e5e5e5;

    .img {
      flex: 1;

      img {
        width: 90px;
        margin: auto;
      }
    }

    .txt {
      flex: 3;
      text-indent: 10px;

      h4 {
        font-size: 14px;
        color: #333;
        font-weight: 600;
        margin-top: 8px;
      }
    }
  }
}

.item {
  .txt {
    span {
      font-size: 14px;
      color: #ff0000;
      display: block;
      height: 28px;
      line-height: 28px;
    }
  }
}

.group {
  .col {
    display: flex;
    color: #fff;
    text-align: center;

    & > div {
      font-size: 14px;
      height: 30px;
      line-height: 30px;
    }

    strong {
      font-size: 16px;
    }
  }

  .first {
    flex: 2;
    background-color: #018298;
  }

  .second {
    flex: 1;
    background-color: #1255ca;
  }

  .last {
    flex: 1;
    background-color: #542fb0;
  }
}
</style>